import time
# fp = open("test", mode='r', encoding='utf-8') # r
# fd = open('newFile', mode='r', encoding='utf-8')
# content = fp.read()
# # print(content)
# fd.write(content)
# fp.close()
# fd.close()

# with open("test", mode='r', encoding='utf-8') as r_fp, open('newFile', mode='a', encoding='utf-8') as w_fp:
#     w_fp.write(r_fp.read())

# fp = open("test", mode='r', encoding='utf-8')
# context = fp.readlines()
# for line in context:
#     print(line.strip())
# while True:  # False：0 True： 1
#     line = fp.readline()
#     if line:
#         print(line.strip())
#     else:
#         print("等待文件内容中。。。。。")
#         time.sleep(1)

fp = open("newFile",mode='w',encoding='utf-8')  # 字母、数字 1位  中文 3位
fp.write("king")
fp.seek(2)
fp.truncate() # 截断删除
fp.close()
